package com.cn.lp.export.server.base.context;


import com.cn.lp.export.server.base.result.ResultCode;

/**
 * Created by xiaoqing on 2018/5/6.
 */
public class ResponseResult<O> implements CommandResult<O> {

    /**
     * 结果码
     */
    private int resultCode;

    /**
     * 是否成功
     */
    private boolean success;

    /**
     * 消息
     */
    private O message;

    /**
     * 异常信息
     */
    private Object errorMsg;

    public ResponseResult setMessage(O message) {
        this.message = message;
        return this;
    }

    public ResponseResult setResultCode(int resultCode) {
        this.resultCode = resultCode;
        this.success = resultCode == ResultCode.SUCCESS_CODE;
        return this;
    }

    public ResponseResult<O> setErrorMsg(Object errorMsg) {
        this.errorMsg = errorMsg;
        return this;
    }

    @Override
    public int getResultCode() {
        return resultCode;
    }

    @Override
    public boolean isSuccess() {
        return this.success;
    }

    @Override
    public O getMessage() {
        return message;
    }

    @Override
    public Object getErrorMsg() {
        return errorMsg;
    }
}
